package app.dev.telemetric;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import app.dev.telemetric.protocol.ExpertProtocol;
import app.dev.telemetric.server.Server;

public class LaunchServer extends Thread {
    private Server server;
    private ApplicationContext applicationContext=new ClassPathXmlApplicationContext("serverContext.xml");
    
    public LaunchServer()
    {
    	server=applicationContext.getBean("server", Server.class);
    }
    
    public void run()
    {
		ExpertProtocol expertProtocol=applicationContext.getBean("expertProtocol", ExpertProtocol.class);
		server.setApplicationContext(applicationContext);
		
		expertProtocol.LoadProtocols(applicationContext);
		server.setPort(7500);
		server.start();
    }
    
    public void StopServer()
    {
    	server.StopService();
    }

	public boolean IsRun() {
		return server.IsRun();
	}
	
}
